<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>命令行常用技巧 | Guru Note</title>
    <meta name="generator" content="VuePress 1.7.1">
    <link rel="stylesheet" href="./font/index.css">
    <script src="/docs/icon/svg.js"></script>
    <meta name="description" content="Sea of dawn">
    
    <link rel="preload" href="/docs/assets/css/0.styles.efa081cd.css" as="style"><link rel="preload" href="/docs/assets/js/app.cdec4db9.js" as="script"><link rel="preload" href="/docs/assets/js/2.993bd611.js" as="script"><link rel="preload" href="/docs/assets/js/21.287b744a.js" as="script"><link rel="preload" href="/docs/assets/js/7.5a12abef.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.c3177bdb.js"><link rel="prefetch" href="/docs/assets/js/100.60c23478.js"><link rel="prefetch" href="/docs/assets/js/101.7ea29e1b.js"><link rel="prefetch" href="/docs/assets/js/102.7f47e485.js"><link rel="prefetch" href="/docs/assets/js/103.ea9ce400.js"><link rel="prefetch" href="/docs/assets/js/104.4ec6a518.js"><link rel="prefetch" href="/docs/assets/js/105.75526347.js"><link rel="prefetch" href="/docs/assets/js/106.01f6b03b.js"><link rel="prefetch" href="/docs/assets/js/107.69fe0811.js"><link rel="prefetch" href="/docs/assets/js/108.fa23768b.js"><link rel="prefetch" href="/docs/assets/js/109.90df1698.js"><link rel="prefetch" href="/docs/assets/js/11.54347528.js"><link rel="prefetch" href="/docs/assets/js/110.dd8d7227.js"><link rel="prefetch" href="/docs/assets/js/111.ccf25ceb.js"><link rel="prefetch" href="/docs/assets/js/112.6963298f.js"><link rel="prefetch" href="/docs/assets/js/113.30ceb3d8.js"><link rel="prefetch" href="/docs/assets/js/114.42ef6603.js"><link rel="prefetch" href="/docs/assets/js/115.f1db7817.js"><link rel="prefetch" href="/docs/assets/js/116.92971223.js"><link rel="prefetch" href="/docs/assets/js/117.c5a65e7e.js"><link rel="prefetch" href="/docs/assets/js/118.e329035d.js"><link rel="prefetch" href="/docs/assets/js/119.cbb17c5e.js"><link rel="prefetch" href="/docs/assets/js/12.c8144ee8.js"><link rel="prefetch" href="/docs/assets/js/120.8537f6a6.js"><link rel="prefetch" href="/docs/assets/js/121.257d3851.js"><link rel="prefetch" href="/docs/assets/js/122.96a5f921.js"><link rel="prefetch" href="/docs/assets/js/123.2220fd12.js"><link rel="prefetch" href="/docs/assets/js/124.552b1a29.js"><link rel="prefetch" href="/docs/assets/js/125.4e36fe37.js"><link rel="prefetch" href="/docs/assets/js/126.3939cdcc.js"><link rel="prefetch" href="/docs/assets/js/127.014df434.js"><link rel="prefetch" href="/docs/assets/js/13.edc237a8.js"><link rel="prefetch" href="/docs/assets/js/14.66270d4f.js"><link rel="prefetch" href="/docs/assets/js/15.0804164b.js"><link rel="prefetch" href="/docs/assets/js/16.dec928ab.js"><link rel="prefetch" href="/docs/assets/js/17.bbfc90a8.js"><link rel="prefetch" href="/docs/assets/js/18.76904860.js"><link rel="prefetch" href="/docs/assets/js/19.80a98011.js"><link rel="prefetch" href="/docs/assets/js/20.c39e42bd.js"><link rel="prefetch" href="/docs/assets/js/22.c9506be7.js"><link rel="prefetch" href="/docs/assets/js/23.9732a229.js"><link rel="prefetch" href="/docs/assets/js/24.21ed1f05.js"><link rel="prefetch" href="/docs/assets/js/25.8f1926f6.js"><link rel="prefetch" href="/docs/assets/js/26.61b6eb9f.js"><link rel="prefetch" href="/docs/assets/js/27.3706753c.js"><link rel="prefetch" href="/docs/assets/js/28.b6b182cf.js"><link rel="prefetch" href="/docs/assets/js/29.ae979ad9.js"><link rel="prefetch" href="/docs/assets/js/3.a7f8dd77.js"><link rel="prefetch" href="/docs/assets/js/30.f2233269.js"><link rel="prefetch" href="/docs/assets/js/31.06780314.js"><link rel="prefetch" href="/docs/assets/js/32.2dad91d1.js"><link rel="prefetch" href="/docs/assets/js/33.87ec6e22.js"><link rel="prefetch" href="/docs/assets/js/34.7b75f220.js"><link rel="prefetch" href="/docs/assets/js/35.3184991f.js"><link rel="prefetch" href="/docs/assets/js/36.28248fbe.js"><link rel="prefetch" href="/docs/assets/js/37.5824a979.js"><link rel="prefetch" href="/docs/assets/js/38.99a364fe.js"><link rel="prefetch" href="/docs/assets/js/39.a5f43732.js"><link rel="prefetch" href="/docs/assets/js/4.a55d89ed.js"><link rel="prefetch" href="/docs/assets/js/40.629f78f7.js"><link rel="prefetch" href="/docs/assets/js/41.e4f58d1c.js"><link rel="prefetch" href="/docs/assets/js/42.9f41aa47.js"><link rel="prefetch" href="/docs/assets/js/43.636412b6.js"><link rel="prefetch" href="/docs/assets/js/44.3b491aef.js"><link rel="prefetch" href="/docs/assets/js/45.77df19bc.js"><link rel="prefetch" href="/docs/assets/js/46.01f53ddd.js"><link rel="prefetch" href="/docs/assets/js/47.476e85c9.js"><link rel="prefetch" href="/docs/assets/js/48.198502dc.js"><link rel="prefetch" href="/docs/assets/js/49.0d59d332.js"><link rel="prefetch" href="/docs/assets/js/5.1597c0f8.js"><link rel="prefetch" href="/docs/assets/js/50.02baf101.js"><link rel="prefetch" href="/docs/assets/js/51.c9fbd54d.js"><link rel="prefetch" href="/docs/assets/js/52.4cb4459b.js"><link rel="prefetch" href="/docs/assets/js/53.248450d7.js"><link rel="prefetch" href="/docs/assets/js/54.83f12d1e.js"><link rel="prefetch" href="/docs/assets/js/55.b18accba.js"><link rel="prefetch" href="/docs/assets/js/56.8a160b09.js"><link rel="prefetch" href="/docs/assets/js/57.b854a940.js"><link rel="prefetch" href="/docs/assets/js/58.4500f315.js"><link rel="prefetch" href="/docs/assets/js/59.59400e36.js"><link rel="prefetch" href="/docs/assets/js/6.887ba020.js"><link rel="prefetch" href="/docs/assets/js/60.4dd5b5bb.js"><link rel="prefetch" href="/docs/assets/js/61.50d8c8f6.js"><link rel="prefetch" href="/docs/assets/js/62.17d10daa.js"><link rel="prefetch" href="/docs/assets/js/63.d5f821cc.js"><link rel="prefetch" href="/docs/assets/js/64.7bf2519f.js"><link rel="prefetch" href="/docs/assets/js/65.0a1c9bc8.js"><link rel="prefetch" href="/docs/assets/js/66.1bcaa81c.js"><link rel="prefetch" href="/docs/assets/js/67.326bdf9b.js"><link rel="prefetch" href="/docs/assets/js/68.2b3b63b2.js"><link rel="prefetch" href="/docs/assets/js/69.c9b1a1a9.js"><link rel="prefetch" href="/docs/assets/js/70.a5fede78.js"><link rel="prefetch" href="/docs/assets/js/71.288d9643.js"><link rel="prefetch" href="/docs/assets/js/72.8665d6b8.js"><link rel="prefetch" href="/docs/assets/js/73.47155429.js"><link rel="prefetch" href="/docs/assets/js/74.4d4738f8.js"><link rel="prefetch" href="/docs/assets/js/75.659a325f.js"><link rel="prefetch" href="/docs/assets/js/76.a263f692.js"><link rel="prefetch" href="/docs/assets/js/77.9d86d59e.js"><link rel="prefetch" href="/docs/assets/js/78.a41b5d88.js"><link rel="prefetch" href="/docs/assets/js/79.5d0fc4cc.js"><link rel="prefetch" href="/docs/assets/js/8.80d0c81d.js"><link rel="prefetch" href="/docs/assets/js/80.01a11f6a.js"><link rel="prefetch" href="/docs/assets/js/81.9c0207d9.js"><link rel="prefetch" href="/docs/assets/js/82.12be8e04.js"><link rel="prefetch" href="/docs/assets/js/83.00fa5f46.js"><link rel="prefetch" href="/docs/assets/js/84.f14cd53c.js"><link rel="prefetch" href="/docs/assets/js/85.e9d7c0d1.js"><link rel="prefetch" href="/docs/assets/js/86.eb78fbbf.js"><link rel="prefetch" href="/docs/assets/js/87.8a31f5ae.js"><link rel="prefetch" href="/docs/assets/js/88.0f10e6dc.js"><link rel="prefetch" href="/docs/assets/js/89.a17253c9.js"><link rel="prefetch" href="/docs/assets/js/9.2fa568cb.js"><link rel="prefetch" href="/docs/assets/js/90.e56bc609.js"><link rel="prefetch" href="/docs/assets/js/91.5277db18.js"><link rel="prefetch" href="/docs/assets/js/92.b0bb8aa7.js"><link rel="prefetch" href="/docs/assets/js/93.cd790b77.js"><link rel="prefetch" href="/docs/assets/js/94.76bbe227.js"><link rel="prefetch" href="/docs/assets/js/95.4f07ca32.js"><link rel="prefetch" href="/docs/assets/js/96.2b1e8485.js"><link rel="prefetch" href="/docs/assets/js/97.e93b3461.js"><link rel="prefetch" href="/docs/assets/js/98.658063a1.js"><link rel="prefetch" href="/docs/assets/js/99.a3642e6d.js">
    <link rel="stylesheet" href="/docs/assets/css/0.styles.efa081cd.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">Guru Note</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----> <svg aria-hidden="true" class="icon search-icon"><use xlink:href="#icon-search"></use></svg></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/docs/layout/" class="nav-link">
  CSS 手册
</a></div><div class="nav-item"><a href="/docs/js/" class="nav-link">
  JavaScript
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端进阶" class="dropdown-title"><span class="title">前端进阶</span> <span class="arrow down"></span></button> <button type="button" aria-label="前端进阶" class="mobile-dropdown-title"><span class="title">前端进阶</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>
          前端框架
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/docs/vue/" class="nav-link">
  Vue.js
</a></li><li class="dropdown-subitem"><a href="/docs/react/" class="nav-link">
  React.js
</a></li></ul></li><li class="dropdown-item"><h4>
          拓展语言
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/docs/node/" class="nav-link">
  Node.js
</a></li><li class="dropdown-subitem"><a href="/docs/ts/" class="nav-link">
  TypeScript
</a></li></ul></li></ul></div></div><div class="nav-item"><a href="/docs/devbook/" class="nav-link router-link-active">
  开发手册
</a></div><div class="nav-item"><a href="/docs/exam/" class="nav-link">
  金九银十
</a></div><div class="nav-item"><a href="/docs/message/" class="nav-link">
  留言板
</a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><div class="el-scrollbar"><div class="scrollbar-wrapper el-scrollbar__wrap el-scrollbar__wrap--hidden-default"><div class="el-scrollbar__view"><nav class="nav-links"><div class="nav-item"><a href="/docs/layout/" class="nav-link">
  CSS 手册
</a></div><div class="nav-item"><a href="/docs/js/" class="nav-link">
  JavaScript
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端进阶" class="dropdown-title"><span class="title">前端进阶</span> <span class="arrow down"></span></button> <button type="button" aria-label="前端进阶" class="mobile-dropdown-title"><span class="title">前端进阶</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>
          前端框架
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/docs/vue/" class="nav-link">
  Vue.js
</a></li><li class="dropdown-subitem"><a href="/docs/react/" class="nav-link">
  React.js
</a></li></ul></li><li class="dropdown-item"><h4>
          拓展语言
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/docs/node/" class="nav-link">
  Node.js
</a></li><li class="dropdown-subitem"><a href="/docs/ts/" class="nav-link">
  TypeScript
</a></li></ul></li></ul></div></div><div class="nav-item"><a href="/docs/devbook/" class="nav-link router-link-active">
  开发手册
</a></div><div class="nav-item"><a href="/docs/exam/" class="nav-link">
  金九银十
</a></div><div class="nav-item"><a href="/docs/message/" class="nav-link">
  留言板
</a></div> <!----></nav>  <ul class="sidebar-links"><li><a href="/docs/devbook/" aria-current="page" class="sidebar-link">介绍</a></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>开发者小记</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/devbook/note/regex-getting-started.html" class="sidebar-link">正则表达式入门</a></li><li><a href="/docs/devbook/note/lisp-getting-started.html" class="sidebar-link">Lisp 入门</a></li><li><a href="/docs/devbook/note/search-skill.html" class="sidebar-link">搜索引擎常用技巧</a></li><li><a href="/docs/devbook/note/the-http.html" class="sidebar-link">HTTP 相关知识科普</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>环境搭建</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/devbook/setting/node-use.html" class="sidebar-link">Node.js 安装教程</a></li><li><a href="/docs/devbook/setting/cmder-install.html" class="sidebar-link">Cmder 配置教程</a></li><li><a href="/docs/devbook/setting/vscode-and-cmder-use.html" class="sidebar-link">VSCode 与 Cmder 配合使用</a></li><li><a href="/docs/devbook/setting/tool-recommend.html" class="sidebar-link">Windows 常用工具</a></li><li><a href="/docs/devbook/setting/webstorm.html" class="sidebar-link">WebStorm 配置</a></li><li><a href="/docs/devbook/setting/vscode.html" class="sidebar-link">VSCode 配置</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>命令行工具</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/devbook/cli-plugin.html" class="sidebar-link">命令行常用插件</a></li><li><a href="/docs/devbook/cli-hot-key.html" class="sidebar-link">命令行快捷键</a></li><li><a href="/docs/devbook/git-getting-started.html" class="sidebar-link">Git 命令入门</a></li><li><a href="/docs/devbook/git-many-remotely.html" class="sidebar-link">Git 关联多个远程仓库</a></li><li><a href="/docs/devbook/mobile-file.html" class="sidebar-link">文件操作命令</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>博客搭建</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/devbook/hexo-build-blog.html" class="sidebar-link">Hexo 搭建博客教程</a></li><li><a href="/docs/devbook/hexo-generate.html" class="sidebar-link">Hexo 生成永久链接</a></li><li><a href="/docs/devbook/hexo-theme.html" class="sidebar-link">Hexo 主题推荐</a></li><li><a href="/docs/devbook/hugo-created-blog.html" class="sidebar-link">Hugo 搭建个人博客</a></li></ul></section></li></ul> </div></div><div class="el-scrollbar__bar is-horizontal"><div class="el-scrollbar__thumb" style="width:0;transform:translateX(0%);ms-transform:translateX(0%);webkit-transform:translateX(0%);"></div></div><div class="el-scrollbar__bar is-vertical"><div class="el-scrollbar__thumb" style="height:0;transform:translateY(0%);ms-transform:translateY(0%);webkit-transform:translateY(0%);"></div></div></div></aside> <main class="page"> <div class="re-page-top"><h1 class="title"><span>命令行常用技巧</span></h1> <div class="re-page-index"><div class="page-index-title"><span class="open-catalog"><svg aria-hidden="true" class="icon arrow-right"><use xlink:href="#icon-bold-right"></use></svg> <span class="text">目录</span></span></div> <div class="page-index-content"><div class="page-catalog" style="display:none;"><div class="synopsis-wrap"><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#目录跳转" class="synopsis-link">目录跳转</a><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#快速跳转" class="synopsis-link">快速跳转</a></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#简化版快速跳转" class="synopsis-link">简化版快速跳转</a></li></ul></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#配置-bashrc" class="synopsis-link">配置.bashrc</a><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#简洁的-git-命令" class="synopsis-link">简洁的 git 命令</a></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#打开文件" class="synopsis-link">打开文件</a></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#历史" class="synopsis-link">历史</a></li></ul></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#装一个好看的字体" class="synopsis-link">装一个好看的字体</a></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#添加tree命令" class="synopsis-link">添加tree命令</a><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#安装tree" class="synopsis-link">安装tree</a></li></ul></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#翻译工具" class="synopsis-link">翻译工具</a></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#快捷打开当前项目所在-github-链接" class="synopsis-link">快捷打开当前项目所在 GitHub 链接</a></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#命令行中的快捷键" class="synopsis-link">命令行中的快捷键</a><ul class="synopsis-ul"><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#搜索历史" class="synopsis-link">搜索历史</a></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#删除当前行" class="synopsis-link">删除当前行</a></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#其他快捷键" class="synopsis-link">其他快捷键</a></li></ul></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#安装ubuntu" class="synopsis-link">安装Ubuntu</a></li><li class="synopsis-li"><a href="/docs/devbook/cil-used-skill.html#拓展" class="synopsis-link">拓展</a></li></ul></div></div></div></div></div> <div class="theme-default-content content__default"><h2 id="目录跳转"><a href="#目录跳转" class="header-anchor">#</a> 目录跳转</h2> <p>跳转至用户目录 <code>cd ~/</code></p> <p>查看当前目录 <code>pwd</code></p> <p>打开指定文件 <code>start 路径</code></p> <h3 id="快速跳转"><a href="#快速跳转" class="header-anchor">#</a> 快速跳转</h3> <p><strong>安装</strong></p> <blockquote><p>注：如果觉得文字过多步骤繁琐，下面有简化版</p></blockquote> <p>在用户目录下创建一个文件夹进入这个目录</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">mkdir</span> ~/GitHub/rupa
<span class="token builtin class-name">cd</span> ~/GitHub/rupa
</code></pre></div><p>下载 z 命令的文件：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">git</span> clone https://github.com/rupa/z.git
</code></pre></div><p>进入 z 目录 <code>cd z</code></p> <p>使用 <code>pwd</code> 查看当前目录路径，复制 <code>pwd</code> 显示的路径并在路径后添加 <code>/z.sh</code></p> <div class="language- extra-class"><pre class="language-text"><code>/c/Users/xxx/GitHub/rupa/z/z.sh
</code></pre></div><p>可以用 ~ 代替用户目录，如下：</p> <div class="language- extra-class"><pre class="language-text"><code>~/GitHub/rupa/z/z.sh
</code></pre></div><p>用 VSCode (其他编辑器也可以，但是不要使用记事本等打开) 打开 用户目录下的 <code>.bashrc</code> 文件</p> <p>然后把上面的路径复制添加在用户目录 ( <code>cd ~/</code> ) 下的 <code>.bashrc</code> 文件中：</p> <p>在前面加一个 . 并用空格隔开</p> <div class="language- extra-class"><pre class="language-text"><code>. ~/GitHub/rupa/z/z.sh
</code></pre></div><blockquote><p>. 是 source 的缩写 所以也可以写作 source</p></blockquote> <p>在 <code>.bashrc</code> 文件中添加一行以下内容，就可以使用 <code>j</code> 键代替 <code>z</code> 键了</p> <div class="language- extra-class"><pre class="language-text"><code>alias j='z'
</code></pre></div><p><strong>使用</strong></p> <p>使用 <code>j</code> + 任何文件名可以快速跳转至该文件目录，可以不写全称。</p> <p>只输入 <code>j</code> 可显示历史目录</p> <blockquote><p>注：快速跳转只支持去过的历史目录</p></blockquote> <p>文中的 <code>git clone https://github.com/rupa/z.git</code> 来源：</p> <ol><li><p>在 GitHub 仓库搜索 z ，选择 <code>rupa/z</code>，如图：</p> <img src="/docs/images/bash_z-01.png" alt="cil-used"></li> <li><p>之后就可以下载啦</p> <img src="/docs/images/bash_z-02.png" alt="cil-used"></li></ol> <hr> <h3 id="简化版快速跳转"><a href="#简化版快速跳转" class="header-anchor">#</a> 简化版快速跳转</h3> <p>打开命令行工具</p> <ol><li><p><code>mkdir ~/repos</code></p></li> <li><p><code>cd ~/repos</code></p></li> <li><p><code>git clone https://github.com/rupa/z.git</code></p></li> <li><p><code>touch ~/.bashrc</code></p></li> <li><p><code>start ~/.bashrc</code></p> <p>在文件中写入</p> <div class="language- extra-class"><pre class="language-text"><code>. ~/repos/z/z.sh
alias j='z'
</code></pre></div></li> <li><p>重启 Git Bash</p></li> <li><p>你去过的所有目录都会被记录了！使用 <code>j XXX</code> 就可以快速到达之前去过的目录了！</p></li> <li><p>使用 j 可以查看所有去过的目录</p></li></ol> <h2 id="配置-bashrc"><a href="#配置-bashrc" class="header-anchor">#</a> 配置.bashrc</h2> <h3 id="简洁的-git-命令"><a href="#简洁的-git-命令" class="header-anchor">#</a> 简洁的 git 命令</h3> <p>在 <code>~/.bashrc</code> 中添加如下</p> <div class="language- extra-class"><pre class="language-text"><code>alias gst=&quot;git status -sb&quot;
alias ga=&quot;git add&quot;
alias gc=&quot;git commit -v&quot;
alias gcc=&quot;git commit . -m update&quot;
alias gp=&quot;git push&quot;
alias gl=&quot;git pull&quot;
</code></pre></div><p>再执行 <code>. ~/.bashrc</code>  (或者重启命令行)，就可以使用更简洁的 git 命令</p> <blockquote><p><code>. ~/.bashrc</code> 是 <code>source ~/.bashrc</code> 命令的简称以 root 方式进入 Ubuntu</p></blockquote> <h3 id="打开文件"><a href="#打开文件" class="header-anchor">#</a> 打开文件</h3> <p>首先在 <code>~/.bashrc</code> 文件中添加：</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token builtin class-name">alias</span> <span class="token assign-left variable">open</span><span class="token operator">=</span><span class="token string">'start'</span>
</code></pre></div><p>然后在命令行执行 <code>. ~/.bashrc</code></p> <p>即可用 <code>open</code> 代替 <code>start</code> 执行打开文件命令</p> <h3 id="历史"><a href="#历史" class="header-anchor">#</a> 历史</h3> <p>在 <code>~/.bashrc</code> 中添加，查看历史 log 更直观</p> <div class="language- extra-class"><pre class="language-text"><code>alias glog=&quot;git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)&lt;%an&gt;%Creset' --abbrev-commit -- | less&quot;
</code></pre></div><p>然后在命令行执行 <code>. ~/.bashrc</code></p> <p>添加后就可以使用 <code>glog</code> 命令查看当前 git 仓库的历史的提交了</p> <h2 id="装一个好看的字体"><a href="#装一个好看的字体" class="header-anchor">#</a> 装一个好看的字体</h2> <p>先下载：https://github.com/powerline/fonts/tree/master/SourceCodePro</p> <p>最好把每个 <code>.otf</code> 后缀的文件都下载，这样字体的样式很多，下载后全选右键选择安装即可</p> <p>然后重启命令行在设置中选择该字体即可</p> <h2 id="添加tree命令"><a href="#添加tree命令" class="header-anchor">#</a> 添加tree命令</h2> <h3 id="安装tree"><a href="#安装tree" class="header-anchor">#</a> 安装tree</h3> <p>官网：http://gnuwin32.sourceforge.net/packages/tree.htm</p> <p>选择 Complete package, except sources 那一行下载完整包，如图：</p> <img src="/docs/images/bash_tree-01.png" alt="cil-used"> <p>安装成功后在用户目录下的 <code>.bashrc</code> 输入</p> <div class="language- extra-class"><pre class="language-text"><code>export PATH=&quot;$PATH:/C/Software/GnuWin32/bin&quot;
</code></pre></div><p>其中 $PATH: 后的路径为 tree 安装路径下的 bin 路径 (注意路径中的 \ 要修改为 / 格式)</p> <p>然后 <code>. ~/.bashrc</code> 一下</p> <p>然后运行 <code>which tree</code> 如果出现了安装路径就说明成功了</p> <p>使用 <code>tree .</code> 即可查看当前目录</p> <p>这篇教程的原文来自方方老师一篇博客：https://xiedaimala.com/bbs/topics/184#/</p> <h2 id="翻译工具"><a href="#翻译工具" class="header-anchor">#</a> 翻译工具</h2> <p>安装 <code>npm i -g fanyi</code></p> <p>使用 <code>fy hi</code></p> <h2 id="快捷打开当前项目所在-github-链接"><a href="#快捷打开当前项目所在-github-链接" class="header-anchor">#</a> 快捷打开当前项目所在 GitHub 链接</h2> <p>安装</p> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">yarn</span> global <span class="token function">add</span> git-open
<span class="token function">npm</span> <span class="token function">install</span> --global git-open
</code></pre></div><p>使用</p> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">git</span> <span class="token function">open</span> <span class="token punctuation">[</span>remote-name<span class="token punctuation">]</span> <span class="token punctuation">[</span>branch-name<span class="token punctuation">]</span>
    <span class="token comment"># Open the page for this branch on the repo website</span>

<span class="token function">git</span> <span class="token function">open</span> --commit
<span class="token function">git</span> <span class="token function">open</span> -c
   <span class="token comment"># Open the current commit in the repo website</span>

<span class="token function">git</span> <span class="token function">open</span> --issue
<span class="token function">git</span> <span class="token function">open</span> -i
   <span class="token comment"># If this branch is named like issue/#123, this will open the corresponding</span>
   <span class="token comment"># issue in the repo website</span>

<span class="token function">git</span> <span class="token function">open</span> --print
<span class="token function">git</span> <span class="token function">open</span> -p
    <span class="token comment"># Only print the url at the terminal, but don't open it</span>
</code></pre></div><h2 id="命令行中的快捷键"><a href="#命令行中的快捷键" class="header-anchor">#</a> 命令行中的快捷键</h2> <h3 id="搜索历史"><a href="#搜索历史" class="header-anchor">#</a> 搜索历史</h3> <p>首先按一下 <code>ctrl</code> + <code>R</code> 然后输入命令 的一部分</p> <p>然后会显示历史命令，然后按住 <code>ctrl</code> 再按 <code>R</code> 切换历史命令，直到切换到自己想要的，按方向键左右键即可退出</p> <p>如果是需要的命令 按方向键左右即可在当前行显示该命令</p> <p>如果不想搜索 使用 Ctrl + Go 退出搜索</p> <h3 id="删除当前行"><a href="#删除当前行" class="header-anchor">#</a> 删除当前行</h3> <p>按下 <code>ctrl</code> + <code>a</code> 到达命令首字母，然后再按下 <code>ctrl</code> + <code>k</code> 删除本行命令</p> <h3 id="其他快捷键"><a href="#其他快捷键" class="header-anchor">#</a> 其他快捷键</h3> <ul><li>光标移至行首 <code>Ctrl + A</code></li> <li>光标移至行尾 <code>Ctrl + E</code></li> <li>光标退后 <code>Ctrl + B</code></li> <li>光标前进 <code>Ctrl + F</code></li> <li>删一个单词 <code>Ctrl + W</code></li> <li>中断命令 <code>Ctrl + Cancel</code></li> <li>使用上一条命令的最后一个参数 <code>Alt + .</code></li></ul> <p><strong>查看更多快捷键</strong></p> <p>谷歌搜索 <code>bash 快捷键</code>，推荐网址：https://linuxtoy.org/archives/bash-shortcuts.html</p> <h2 id="安装ubuntu"><a href="#安装ubuntu" class="header-anchor">#</a> 安装Ubuntu</h2> <p>在 Win10 的 Microsoft Store 搜索 Ubuntu 下载安装</p> <p><strong>windows目录</strong></p> <p>在 Ubuntu 中 windows 目录在 <code>/mnt/</code> 下</p> <p>如 c 盘 <code>/mnt/c/</code></p> <p><strong>设置快捷打开目录</strong></p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">ln</span> -s /mnt/c/xxx/GitHub/
</code></pre></div><p>设置后直接使用 <code>cd 当前目录</code> 即可</p> <p><strong>打开当前目录文件夹</strong></p> <div class="language-bash extra-class"><pre class="language-bash"><code>explorer.exe <span class="token builtin class-name">.</span>
</code></pre></div><p>你可以将 explorer.exe 设置为 start ，用 vim 打开 <code>vi ~/.bashrc</code></p> <p>按 <code>i</code> 然后在最下方插入 <code>alias start=&quot;explorer.exe&quot;</code></p> <p>然后 <code>:wq</code> 保存</p> <p>然后就可以使用 <code>start .</code> 打开目录了</p> <p><strong>一个报错</strong></p> <div class="language- extra-class"><pre class="language-text"><code>error: 0x8007019e
</code></pre></div><p>解决方法</p> <p>键盘行按键win+x，选择Windows PowerShell（管理员）</p> <p>输入：</p> <div class="language- extra-class"><pre class="language-text"><code>Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
</code></pre></div><p>回车输入Y并重启。 重启打开Ubuntu的命令窗口，等几分钟，输入账户和密码即可。</p> <hr> <p>以下未记录</p> <hr> <p><strong>以 root 方式进入 Ubuntu</strong></p> <p>使用 <code>sudo passwd root</code> 设置 root 的密码 (默认情况下密码在命令行不会显示)</p> <p>设置后输入 <code>su root</code> 输入密码进入</p> <p><strong>在Cmder中添加Ubuntu</strong></p> <p>首先打开设置，在启动中设置以下选项</p> <img src="/docs/images/ubuntu_01.png" alt="cil-used"> <p>然后就可以在 Cmder 中新建 Ubuntu 窗口了</p> <p>也可以把 Ubuntu 设置为默认启动</p> <img src="/docs/images/ubuntu_02.png" alt="cil-used"> <h2 id="拓展"><a href="#拓展" class="header-anchor">#</a> 拓展</h2> <p><strong>复制粘贴快捷键</strong></p> <p>Git Bash 粘贴：按住鼠标中键，或者 Shift + Ins 是复制</p> <p>cmd 复制：选中然后按回车键</p> <p><strong>npm 命令卸载插件</strong></p> <div class="language- extra-class"><pre class="language-text"><code>npm uninstall 插件名 -g
</code></pre></div></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">上次更新：</span><span class="time">2021-04-06 22:40</span></div></footer> <!----> </main></div><div class="global-ui"><!----><!----></div></div>
    <script src="/docs/assets/js/app.cdec4db9.js" defer></script><script src="/docs/assets/js/2.993bd611.js" defer></script><script src="/docs/assets/js/21.287b744a.js" defer></script><script src="/docs/assets/js/7.5a12abef.js" defer></script>
  </body>
</html>
